<?php
define('OFFSET_PATH',4);

require_once('../../zp-core/functions-basic.php');
require_once(SERVERPATH."/".ZENFOLDER.'/template-functions.php');
require_once(SERVERPATH."/".ZENFOLDER.'/controller.php');
require_once(SERVERPATH."/".ZENFOLDER.'/classes.php');
require_once(SERVERPATH.'/'.ZENFOLDER.'/functions.php');


switch($_GET['op']) {
	// Hitcounter handler for zenonfly
	case "1" :
		$album_name = sanitize($_GET["album"]);
		$img_name = sanitize($_GET["img"]);

		if ($album_name && $img_name ) {
			$gallery = new Gallery();
			$album = new Album($gallery, $album_name);
			$image = newImage($album, $img_name);	
			//update hit counter
			if (!isMyALbum($album->name, ALL_RIGHTS)) {
				$hc = $image->get('hitcounter')+1;
				$image->set('hitcounter', $hc);
				$image->save();
			}
		}	
	// Rating handler for zenonfly
	case "2" : 
		require_once(SERVERPATH.'/'.ZENFOLDER.'/'.PLUGIN_FOLDER.'/rating.php');

		$album_name = sanitize($_GET["albumname"]);
		$img_name = sanitize($_GET["filename"]);
		
		if ($album_name && $img_name ) {
			global $_zp_current_image;
			$gallery = new Gallery();
			$album = new Album($gallery, album_name);
			$_zp_current_image = new _Image($album, $img_name);
			printRating(3,$_zp_current_image);
		}
	break;
}

?>